/**
 * Created by DING on 2025/3/27.
 * */
#ifndef PYTHONTASK_PYCPP
#define PYTHONTASK_PYCPP

#include "TaskModule.h"
#include "../GlobalParameters.h"
#include <Python.h>
#include <mutex>
#include <vector>
// 在包含numpy头文件之前添加宏定义
#define NPY_NO_DEPRECATED_API NPY_1_26_API_VERSION
#include <numpy/arrayobject.h>  // NumPy支持
#include <thread>
#include <iostream>

extern "C" BaseObject *createPythonTask();
extern "C" void destroyPythonTask(BaseObject *p);

class PythonTask : public TaskModule {
public:
    PythonTask();

    ~PythonTask();

    void onCompute(buffer_table_t *input, buffer_table_t *output) override;
    int thread_safe_compute(const std::vector<std::complex<float>>& data, buffer_table_t *output);
private:
    PyThreadState* main_state;
    PyObject* pModule;
    PyObject* pFunc;
};

#endif //TASK4_DYHHW_2
